package com.ishare.common.dao;

import com.ishare.common.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author 李嘉宾
 */
@Repository
public interface UserDao extends JpaRepository<User, Integer> {

    /**
     * 添加用戶分值
     * @param userId 用戶ID
     * @param changeScore 添加的分值
     * @return
     */
    @Modifying
    @Query(value = "update User set score=score+?2 where id=?1")
    int addUserScore(Integer userId, Long changeScore);

}
